<template>
  <div id='shenhe'>
    <com-head :opacity='0'>会员管理</com-head>
    <div class="navimg"  @click="shownav"><img class="img" src="../assets/image/navall.png"></div>
    <div class="box1">
      <div class="item"><span>我的账户</span><input type="text" v-model="account" readonly></div>
      <div class="item item3"><span>金币余额</span><input type="text" v-model="money" readonly></div>
    </div>

    <div class="box1 box2">
      <div class="item1">激活账户</div>
      <div class="item item2"><input type="text" v-model="gradeaccount" placeholder="请输入要激活的账号"></div>
      <div class="item"><span>所需金币</span><input type="text" v-model="coin" readonly></div>
      <div class="item item3"><span>二级密码</span><input type="password" v-model="safepsw" placeholder="请输入二级密码"></div>
    </div>
    <com-button :click="jihuo" :disabled="disabled">确定激活</com-button>
    <router-link class="cengji" tag="div" to="hierarchy">查看我的层级</router-link>
  </div>
</template>

<script>
export default {
  name: "shenhe",
  data() {
    return {
      disabled: false,
      account: "",
      money: "",
      gradeaccount: "",
      coin: '',
      password: '',
      safepsw: ''
    };
  },

  computed: {},

  created() {},

  mounted() {
    this.loading()
  },

  methods: {
    loading() {
      this.axios.post("apireg/member", {
          token: this.token()
        })
        .then(({ data }) => {
          
        if (data.code === "200") {
            this.account = data.data.user_num;
            this.money = data.data.regcur;
            this.coin = data.data.num;
          } else if (data.code === "204") {
            this.$bus.$emit("toast", data.data);
          }
        })
        .catch(function(error) {
          console.log(error);
        });
    },
    jihuo() {
      this.disabled = true;
      this.axios.post("apiindex/do_active", {
          token: this.token(),
          user_num: this.gradeaccount,
          sale_code: this.safepsw,
        })
        .then(({ data }) => {
          
        if (data.code === "200") {
            this.$bus.$emit("toast", data.data);
            this.gradeaccount = '';
            this.safepsw = '';
            this.disabled = false;
          } else if (data.code === "204") {
            this.$bus.$emit("toast", data.data);
            this.disabled = false;
          }
        })
        .catch(function(error) {
          console.log(error);
        });
    },
    shownav() {
      this.$bus.$emit("navlist");
    }
  }
};
</script>
<style lang='scss'>
#shenhe {
  text-align: center;
  .icon-fanhui1 {
    display: none;
  }
  .com_button {
    width: 686px;
  }
  .cengji {
    display: inline-block;
    margin: 50px auto;
    text-align: center;
    border-bottom: 1Px solid #000;
  }
  .navimg {
    width: 140px;
    height: 80px;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    img {
      display: block;
      margin-left: 42px;
      margin-top: 25px;
      width: 43px;
      height: 33px;
    }
  }
  .box1 {
    margin-top: 20px;
    width: 750px;
    // height: 190px;
    background-color: #fff;
    .item {
      margin: 0px 30px;
      display: flex;
      justify-content: space-between;
      border-bottom: 1Px solid rgba(238, 238, 238, 1);
      line-height: 102px;
      background-color: #fff;
      span {
        width: 200px;
        text-align: left;
      }
      input {
        width: 450px;
        // height: 52px;
        text-align: right;
        font-size: 30px;
        margin-right: 0;
        color: #054a5e;
      }
      input::-webkit-input-placeholder {
        /* WebKit browsers */
        color: #999;
      }
      input:-moz-placeholder {
        /* Mozilla Firefox 4 to 18 */
        color: #999;
      }

      input::-moz-placeholder {
        /* Mozilla Firefox 19+ */
        color: #999;
      }

      input:-ms-input-placeholder {
        /* Internet Explorer 10+ */
        color: #999;
      }
    }
    .item3 {
      border-bottom: none;
    }
  }
  .box2 {
    margin-top: 20px;
    padding: 20px 0;
    .item1 {
      text-align: left;
      padding-left: 32px;
      box-sizing: border-box;
    }
    .item2 {
      // padding-left: 32px;
      box-sizing: border-box;
      input {
        text-align: left;
        line-height: 80px;
      }
    }
    
  }
}
</style>